
#ifndef PROJECTZ_NUSER_NCOMMAND_CS_SKILL_REGIST_QUICK_SLOT_H_
#define PROJECTZ_NUSER_NCOMMAND_CS_SKILL_REGIST_QUICK_SLOT_H_

#include "../../engine.h"

#include "../../User.h"

#include "../../NLogic/Bag.h"
#include "../../NLogic/Item.h"

namespace ProjectZ { namespace NCommand { namespace NWorld {

class CS_REGIST_QUICK_SLOT
{
public:
	static void OnExecute(User * pUser, ::Network::Packet * pPacket)
	{
		/*
		 * // 퀵등록
		CS_REGIST_QUICK_SLOT	0x0925
		{
			u8	type;		/// 아이템 1,  스킬 2 ( 그 슬롯 인덱스에 아무것도 없을때 NONE = 0 )
			u64	item_seq;		/// 아이템 일시 아이템 시퀀스, , 스킬일시 스킬 인덱스
			u8	regist_quick_slot_idx
		}

		//
		SC_REGIST_QUICK_SLOT	0x0926
		{
			s16	ack;			/// 1:완료 ,  -1 실패
			u8	type;			/// 아이템 1,  스킬 2 ( 그 슬롯 인덱스에 아무것도 없을때 NONE = 0 )
			u64	item_seq;
			u8	regist_quick_slot_idx
		}
		 */

		PREPARE_PACKET;

		uint8_t type = 0;
		uint64_t item_seq = 0;
		uint8_t regist_quick_slot_idx = 0;

		* pPacket >> type >> item_seq >> regist_quick_slot_idx;

		if (1 != type && 2 != type)
		{
			DEBUGLOG("CS_REGIST_QUICK_SLOT type error : %d", type);
			return;
		}

		if (0 > regist_quick_slot_idx || regist_quick_slot_idx > 7)
		{
			DEBUGLOG("CS_REGIST_QUICK_SLOT regist_quick_slot_idx error : %d", regist_quick_slot_idx);
			return;
		}

		if (2 == type)
		{
			if (0 > item_seq || item_seq > 20)
			{
				DEBUGLOG("CS_REGIST_QUICK_SLOT 2 == type item_seq error : %d", item_seq);
				return;
			}

			if (0 > pUser->GetCharacterInfo().array_Skill[item_seq])
			{
				DEBUGLOG("CS_REGIST_QUICK_SLOT 2 == type array_Skill item_seq error : %d", item_seq);
				return;
			}

			pUser->GetCharacterInfo().array_QuickSlot[regist_quick_slot_idx].type = type;
			pUser->GetCharacterInfo().array_QuickSlot[regist_quick_slot_idx].index = item_seq;
		}
		else if (1 == type)
		{

//			int company = pUser->GetCompany();
//			if (0 == regist_quick_slot_idx && 4 == company)
//			{
//				DEBUGLOG("CS_REGIST_QUICK_SLOT 1 == type IsExistItem error : %d", item_seq);
//
//				::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
//				pAck->MsgCat("%2d%c%8d%c", ACK_UNKNOWN_ERROR, type, item_seq, regist_quick_slot_idx);
//				pAck->MakePacket(CMD_SC_REGIST_QUICK_SLOT);
//				pUser->Send(pAck);
//
//				return;
//			}

			if (false == pUser->GetBag(BAG_TYPE_MISC)->IsExistItem(item_seq))
			{
				DEBUGLOG("CS_REGIST_QUICK_SLOT 1 == type IsExistItem error : %d", item_seq);
				return;
			}

			pUser->GetCharacterInfo().array_QuickSlot[regist_quick_slot_idx].type = type;
			pUser->GetCharacterInfo().array_QuickSlot[regist_quick_slot_idx].index = item_seq;
		}
		else
		{
			return;
		}

		::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
		pAck->MsgCat("%2d%c%8d%c", ACK_OK, type, item_seq, regist_quick_slot_idx);
		pAck->MakePacket(CMD_SC_REGIST_QUICK_SLOT);
		pUser->Send(pAck);
	}
};

} /*NWorld*/ } /*NCommand*/ } /*ProjectZ*/


#endif /* PROJECTZ_NUSER_NCOMMAND_CS_SKILL_REGIST_QUICK_SLOT_H_ */
